let baseURL = 'http://127.0.0.1:3000';

function post(obj){
    console.log(obj)
    let arr = [];
    for(var k in obj.data) {
		arr.push(k + '=' + obj.data[k])
	}
    let str =arr.join('&');
    let xhr = new XMLHttpRequest();
    console.log(str);
    xhr.open(obj.type,baseURL+obj.url);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(str);
    xhr.onload = ()=>{
        let str = JSON.parse(xhr.responseText);
        console.log(str);
        obj.success(str);
    }
}


function get(obj){
    let arr = [];
    for(let key in obj.data){
        arr.push([key,obj.data[key]].join('='));
    }
    let str = arr.join('&');
    console.log(str)
    let xhr = new XMLHttpRequest();
    xhr.open(obj.type,baseURL+obj.url + '?'+str);
    xhr.send();
    xhr.onload = ()=>{
        let str = JSON.parse(xhr.responseText);
        obj.success(str);
    }
}